Skip to content

feat(python): add ContentCaptureMode for SDK-level content stripping#22

Draft
alexander-akhmetov wants to merge 1 commit intomainfrom
alexander-akhmetov/content-mode-python
Draft

feat(python): add ContentCaptureMode for SDK-level content stripping#22
alexander-akhmetov wants to merge 1 commit intomainfrom
alexander-akhmetov/content-mode-python

Conversation

@alexander-akhmetov
Copy link
Copy Markdown
Collaborator

@alexander-akhmetov alexander-akhmetov commented Apr 10, 2026

Note

Medium Risk
Adds new content-capture/stripping paths that alter exported generation payloads, tool span attributes, and error reporting based on configuration and context; mistakes could lead to unexpected data leakage or over-redaction.

Overview
Introduces ContentCaptureMode (client-, per-generation-, per-tool-, and context-level) to control whether user/tool content is exported and attached to OTel spans, including a new fail-closed resolver callback (ClientConfig.content_capture_resolver).

When METADATA_ONLY is effective, the SDK now stamps sigil.sdk.content_capture_mode into generation metadata, strips prompts/messages/tool schemas and tool-call/result payloads from generation exports, suppresses provider/mapping exception recording and span status messages, and also strips conversation rating comment before HTTP submission; validation logic is updated to accept structurally-present but empty text/thinking parts under the stripped marker.

Adds context helpers (with_content_capture_mode, content_capture_mode_from_context) with a stack mechanism so nested/overlapping generation recorders don’t clobber caller overrides, plus a comprehensive test_content_capture.py covering mode precedence, stripping, tool span behavior, backward compatibility with include_content, and rating comment stripping.

Reviewed by Cursor Bugbot for commit 7a90384. Bugbot is set up for automated code reviews on this repo. Configure here.

@alexander-akhmetov alexander-akhmetov force-pushed the alexander-akhmetov/content-mode-python branch from a02cff1 to 71e2cf2 Compare April 11, 2026 18:41
cursor[bot]

This comment was marked as outdated.

@alexander-akhmetov alexander-akhmetov force-pushed the alexander-akhmetov/content-mode-python branch from 71e2cf2 to b0eba76 Compare April 11, 2026 18:51
cursor[bot]

This comment was marked as outdated.

@alexander-akhmetov alexander-akhmetov force-pushed the alexander-akhmetov/content-mode-python branch 2 times, most recently from cfb9638 to 7a90384 Compare April 11, 2026 21:07
@alexander-akhmetov
Copy link
Copy Markdown
Collaborator Author

bugbot review

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 7a90384. Configure here.

Add ContentCaptureMode support. Three modes control how
much content is exported: FULL, NO_TOOL_CONTENT (default), and
METADATA_ONLY. Supports config-level defaults, per-recording overrides,
resolver callbacks, and ContextVar propagation to child tool executions.
@alexander-akhmetov alexander-akhmetov force-pushed the alexander-akhmetov/content-mode-python branch from 7a90384 to 11235f0 Compare April 11, 2026 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant